﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace RFIDStockManagement.Client
{
    public partial class AlertForm : DevExpress.XtraEditors.XtraForm
    {
        private static AlertForm staticForm = new AlertForm();


        private bool _confirmResult;

        public bool ConfirmResult
        {
            get { return _confirmResult; }
        }

        public AlertForm()
        {
            InitializeComponent();
        }

        public string AlertString
        {
            get
            {
                return  labInfo.Text;
            }
            set
            {
                labInfo.Text = value;
            }
        }

        public string AlertCaption
        {
            get
            {
                return this.Text;
            }
            set
            {
                this.Text = value;
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            _confirmResult = false;
            this.Hide();
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            _confirmResult = true;
            this.Hide();
        }

        public void ShowMessage()
        {
            simpleButton1.Text = "确 认";
            simpleButton2.Visible = false;
            this.ShowDialog();
        }

        public void ShowConfirm()
        {
            simpleButton1.Text = "取 消";
            simpleButton2.Visible = true;
            this.ShowDialog();
        }

        public static bool Confirm(string infos, string caption)
        {

            if (staticForm == null)
            {
                staticForm = new AlertForm();
            }

            staticForm.AlertString = infos;
            staticForm.AlertCaption = caption;

            staticForm.ShowConfirm();

            return staticForm.ConfirmResult;

        }

        public static void ShowMessage(string infos,string caption)
        {
            if (staticForm == null)
            {
                staticForm = new AlertForm();
            }

            staticForm.AlertString = infos;
            staticForm.AlertCaption = caption;

            staticForm.ShowMessage();

        }

    }
}